package com.maoxx.libms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.maoxx.libms.entity.Book;
import com.maoxx.libms.mapper.BookMapper;
import com.maoxx.libms.service.IBookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2024-10-25
 */
@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements IBookService {

    @Resource
    private BookMapper bookMapper;

    @Override
    public PageInfo<Book> findBookPage(int pageNum, int pageSize, Character status) {
        PageHelper.startPage(pageNum, pageSize);
        List<Book> bookList = new ArrayList<>();
        if (status == null) {
            bookList = bookMapper.selectList(null);
        } else {
            bookList = bookMapper.selectList(new QueryWrapper<Book>().eq("book_status", status));
        }
        return new PageInfo<>(bookList);
    }
}
